package com.itcast.interfacedemo.Demo02;

import com.itcast.abstractdemo.Demo01.A;

import java.util.ArrayList;

/*
要写注释哦!!!
*/
public class StidentInterImpl2 implements StudentInter {
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("=====" + "学生" + (i + 1) + "=====");
            System.out.println("姓名：" + student.getName());
            System.out.println("性别：" + student.getSex());
            System.out.println("成绩：" + student.getScore());
        }
    }

    @Override
    public void printAveragerScore(ArrayList<Student> students) {
        double min = students.get(0).getScore();
        double max = students.get(0).getScore();
        double sum = 0;
        double Average = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            sum += student.getScore();
            if (student.getScore() > max) {
                max = student.getScore();
            }
            if (student.getScore() < min) {
                min = student.getScore();
            }
        }
        sum = sum - min - max;
        Average = sum / (students.size() - 2);
        System.out.println("最低分为："+min);
        System.out.println("最高分为："+max);
        System.out.println("去掉最高分和最低分的平均成绩为：" + Average);
    }
}
